#!/bin/bash

dbname=$1
dblogin=$2
dbpassword=$3
rhost1=$4
rlogin1=$5
rpassword1=$6
rhost2=$7
rlogin2=$8
archivepassword=$9

echo "dbname => "$dbname
echo "dblogin => "$dblogin
echo "dbpassword => "$dbpassword
echo "rhost1 => "$rhost1
echo "rlogin1 => "$rlogin1
echo "rpassword1 => "$rpassword1
echo "rhost2 => "$rhost2
echo "rlogin2 => "$rlogin2
echo "archivepassword => "$archivepassword

print_usage()
{
   echo "Usage: $0 <dbname> <dblogin> <dbpassword> <tct-huizhou rhost> <tct-huizhou rlogin> <tct-huizhou rpassword> <tte-cd-juarez rhost> <tte-cd-juarez rlogin> <tte-cd-juarez rpassword> <archivepassword>"
}

if [ "x$archivepassword" == "x" ]; then
   echo "[ERROR] All arguments not available."
   print_usage
   exit 1
fi

echo "`date +'%Y/%m/%d %H:%M:%S'` BASH SCRIPT: Retrieving archives from tte_cd_juarez..."

/data/scripts/getLatamDate.sh $rlogin2 $rhost2> /tmp/getLatamDate.tmp

latamProdDay=`for i in \`cat /tmp/getLatamDate.tmp\`; do echo $i | perl -e 'while (<STDIN>) { if ( $_ =~s/^(\d{2})\/(\d{2})\/\d{2}(\d{2})/$3$1$2/){ print; } }'; done`
echo "latamProdDay => "$latamProdDay

#exit

#theday=`date +'%y%m%d'`
#heday="080312"

#/data/scripts/retrieve_data_lc.sh tte-cd-juarez $rhost2 $rlogin2 $rpassword2 $dbname $dblogin $dbpassword $archivepassword $latamProdDay > /tmp/retrieve_data_tte-cd-juarez.log 2>&1
/data/scripts/retrieve_data_lc.sh tte-cd-juarez $rhost2 $rlogin2 "N/A" $dbname $dblogin $dbpassword $archivepassword $latamProdDay
#cat /tmp/retrieve_data_tte-cd-juarez.log >> /var/log/retrieve_data_tte-cd-juarez.log

echo "end of process."
